package com.example.yk_fx.adapter;

import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.example.yk_fx.R;
import com.example.yk_fx.entity.VideoEntity;
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;

import java.util.List;

public class VideoAdapter extends BaseMultiItemQuickAdapter<VideoEntity.DataBean, BaseViewHolder> {
    public VideoAdapter(@Nullable List<VideoEntity.DataBean> data) {
        super(data);
        addItemType(0, R.layout.item_video_normal);
        addItemType(1,R.layout.item_video_live);
        addItemType(2,R.layout.item_video_quan);
        addItemType(5,R.layout.item_video_normal);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder holder, VideoEntity.DataBean bean) {
        if(bean.getItemType()==0||bean.getItemType()==2||bean.getItemType()==5){
            StandardGSYVideoPlayer gsy = holder.findView(R.id.gsy);
            gsy.setUp(bean.getVideopath(),true,"");
            gsy.getBackButton().setVisibility(View.GONE);
            gsy.startPlayLogic();

            //横屏观看
            gsy.setAutoFullWithSize(false);
            gsy.setShowFullAnimation(true);
            gsy.setLockLand(true);

        }else{
            StandardGSYVideoPlayer gsy = holder.findView(R.id.gsy);
            gsy.setUp(bean.getVideopath(),true,"");
            gsy.getBackButton().setVisibility(View.GONE);
            gsy.startPlayLogic();
        }
    }
}
